<%@ page language="java" import="com.gxwz.medical.domain.*" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%--引入自定义标签--%>
<%@ include file="/common/base.jsp"%>
<%
 //所在乡镇行政区域编码
 String town=(String)session.getAttribute("agencode");
 System.out.print("town:"+town);
 AreaDao areaDao =new AreaDao();
 //根据乡镇编码获取所有村
 List<Area> areaList=areaDao.findChildArea(town, 3);
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">

<title>农民档案列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/admin.css">
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/admin.js"></script>
<!-- 引入第三方弹出对话框JS组件 -->
<script type="text/javascript" src="third/layer/layer.js"></script>
<script type="text/javascript">
//选择不同的村组
function chooseGroup(){
	var val=$("#village").val();
	$.ajax({
		   type: "POST",
		   url: "<%=path%>/system/AreaServlet?m=groupList",
		   data: {"villageID":val},
		   dataType:"json",
		   success: function(data){
			 $("#group").empty();
			 $("#group").append("<option value=''>默认全部</option>");
		     $.each(data,function(i,val){
		    	 $("#group").append("<option value='"+val.areacode+"'>"+val.areaname+"</option>");
		     });
		   }
		});
}
</script>
</head>
<body>
	<form method="post" action="" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder">农民档案信息列表</strong>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
				   <li>所在村:<select id="village" name="village" class="input"
						   style="width:150px; line-height:17px;display:inline-block" 
							onchange="chooseGroup();">
					
							<% for(Area m:areaList) {%>				
							<option data="<%=m.getParent().getAreaname() %>" value="<%=m.getAreacode()%>"><%=m.getAreaname() %></option>
							<% } %>
						</select>
						所在组：
						<select id="group" name="group" class="input" style="width:150px; line-height:17px;display:inline-block"  >
								<option value="">默认全部</option>
							</select>
						</li>
					<li>关键字（姓名）：</li>
					<li><input type="text" placeholder="请输入搜索关键字" name="keywords"
						class="input"
						style="width:150px; line-height:17px;display:inline-block" /> <a
						href="javascript:void(0)" class="button border-main icon-search"
						onclick="changesearch()"> 搜索</a></li>
					
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th >序号</th>
					<th>家庭编号</th>
					<th>农合证号</th>
					<th>个人姓名</th>
					<th>与户主关系</th>
					<th>性别</th>
					<th>出生年月</th>
					<th>年龄</th>
					<th>身份证号</th>
					<th>乡镇/村/组</th>
					<th>操作</th>
				</tr>
				<%
					String pageNo = request.getParameter("pageNo");
					int p = pageNo == null ? 1 : Integer.parseInt(pageNo);
					PersonDao dao = new PersonDao();
					String sql = "select * from t_person where 1=1 ";
					Object[] params = {};
					Page pageBean = dao.queryOjectsByPage(sql, params, p, Constant.ROW);
				%>
				<%
					for (int i = 0; i < pageBean.getDatas().size(); i++) {

						Person model = (Person) pageBean.getDatas().get(i);
				%>
				<tr>

					<td ><%=i+1 %></td>
					
					<td><%=model.getFamily().getFamicode() %></td>
					<td><%=model.getPerscode() %></td>
					<td><%=model.getPersname() %></td>
					<td><% if("1".equals(model.getRelation())){ %>
					             户主本人
					      <%}else if("2".equals(model.getRelation())){%>
					         配偶
					      <%} else if("3".equals(model.getRelation())){%>
					         子女
					      <%} else if("4".equals(model.getRelation())){%>
					        父母
					    <%} else if("5".equals(model.getRelation())){%>
					         外甥女
					      <%} else if("9".equals(model.getRelation())){%>
					         其他
					      <%} %>
					      </td>
					<td>
					<% if("1".equals(model.getSex())){ %>
					             男
					      <%}else if("2".equals(model.getSex())){%>
					        女
					      <%} %></td>
					<td><%=model.getBirthday() %></td>
					<td><%=model.getAge() %></td>
					<td><%=model.getCardID() %></td>
					<td><%=model.getFamily().getTown().getAreaname()+model.getFamily().getVillage().getAreaname()+model.getFamily().getGroupNo().getAreaname() %></td>
					<td><div class="button-group">
							<a class="button border-main"
								href="<%=path%>/system/PersonSerlvet?m=get&id=<%=model.getPerscode()%>"><span
								class="icon-edit"></span> 修改</a> <a class="button border-red"
								href="<%=path%>/system/PersonSerlvet?m=del&id=<%=model.getPerscode()%>"><span
								class="icon-trash-o"></span> 删除</a>
						</div></td>
				</tr>
				<%
					}
				%>
			</table>
			<div class="pagelist">
				<%
					if (pageBean.hasPre()) {
				%>
				<a
					href="<%=path%>/system/PersonServlet?m=list&pageNo=<%=pageBean.prePage()%>">上一页</a>
				<%
					} else {
				%>
				<a href="javascript:void(0)">上一页</a>
				<%
					}
				%>
				<%
					List<Integer> linkNums = pageBean.linkLumbers();
					for (int num : linkNums) {
						if (pageBean.isCurrent(num)) {
				%>
				<span class="current"><%=num%></span>
				<%
					} else {
				%>
				<a href="<%=path%>/system/PersonServlet?m=list&pageNo=<%=num%>"><%=num%></a>
				<%
					}
					}
				%>
				<%
					if (pageBean.hasNext()) {
				%>
				<a
					href="<%=path%>/system/PersonServlet?m=list&pageNo=<%=pageBean.lastPage()%>">下一页</a>
				<%
					} else {
				%>
				<a href="javascript:void(0)">下一页</a>
				<%
					}
				%>
				<a
					href="<%=path%>/system/PersonServlet?m=list&pageNo=<%=pageBean.getPages()%>">尾页</a>
			</div>
		</div>
	</form>

</body>
</html>
